package com.ming.attendance.mapper;

import com.ming.attendance.po.WxUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface WxUserMapper {

    // 创建用户
    @Insert("INSERT INTO `wx_user`(uuid,openid,session_key,create_time,last_time) VALUES (#{uuid},#{openid},#{sessionKey},#{createTime},#{lastTime});")
    int createUser(WxUser user);

    // 更改用户信息 有要修改的信息和openid
    int updateUser(WxUser user);

    // 通过openid获取session_key
    @Select("SELECT `session_key` FROM `wx_user` WHERE openid = #{openid}")
    String getSessionKey(String openid);

    // 通过openid获取user   含有复杂属性，需要通过xml来进行查询
    WxUser getUser(String openid);
    // 通过uuid获取user
    WxUser getUserByUUID(String uuid);

}
